package sprites;

import java.awt.Graphics2D;
import java.lang.reflect.Constructor;

import com.golden.gamedev.GameObject;

/**
 * The protagonist of the game, controlled by the player.
 */
public class Bob extends BubblefishBobSprite
{
    
    private Projectile currentProjectile;

    public Bob(GameObject owner, double x, double y)
    {
        super(owner, owner.getImages("resources/images/bob.png", 10, 1), x, y);

        setAnimate(true);
        setLoopAnim(true);

        /*
         * 290 is the value from ProgBob. It's near the bottom of the screen.
         * Bob can only move sideways.
         */
        setY(290);
        
        /*
         * Let Bob start out with a random projectile.
         */
        currentProjectile = Projectile.getRandomProjectile(owner, x, y);
    }

    @Override
    public void update(long elapsedTime)
    {
        super.update(elapsedTime);
        currentProjectile.setX(getX());
        currentProjectile.setY(getY());

        /*
         * Make Bob follow the mouse. -23 compensates for Bob's width when the
         * mouse is near the screen edges.
         */
        setX(myOwner.getMouseX() - 23);
    }
    
    public Projectile fire()
    {
        Projectile result = currentProjectile;
        currentProjectile = Projectile.getRandomProjectile(myOwner, getX(), getY());
        return result;
    }
    
    @Override
    public void render(Graphics2D g)
    {
        super.render(g);
        currentProjectile.render(g);
    }
    
    @Override
    /**
     * Bob is not supposed to bob.
     */
    public void bob()
    {
        return;
    }

}
